<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cookie记录访问次数</title>
</head>
<body>
  <%
  //cookie记录次数，保存一天
   //获得cookie
   //查找是否有记录次数的cookie
   //涨一次
   //保存到b端
   Cookie cr[]=request.getCookies();
   Integer count=null;
   for(int i=0;cr!=null&&i<cr.length;i++){
	   if(cr[i].getName().equals("visitnum")){
		   count=Integer.parseInt(cr[i].getValue());
		   break;
	   }
   }
   if(count==null){
	   count=0;
   }
   count++;
   Cookie c=new Cookie("visitnum",String.valueOf(count));
   c.setMaxAge(86400);
   response.addCookie(c);
  %>
  您访问了<%=count%>次
</body>
</html>